// SCSS Mixins 混入文件

// ==================== 布局相关 ====================
// Flex 布局
@mixin flex($direction: row, $justify: flex-start, $align: stretch) {
  display: flex;
  flex-direction: $direction;
  justify-content: $justify;
  align-items: $align;
}

// Flex 居中
@mixin flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

// Flex 两端对齐
@mixin flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

// ==================== 文字相关 ====================
// 文字溢出省略（单行）
@mixin ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// 文字溢出省略（多行）
@mixin multi-ellipsis($lines: 2) {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: $lines;
  overflow: hidden;
  text-overflow: ellipsis;
}

// ==================== 尺寸相关 ====================
// 设置宽高
@mixin size($width, $height: $width) {
  width: $width;
  height: $height;
}

// 固定宽高比
@mixin aspect-ratio($width, $height) {
  position: relative;
  &:before {
    content: '';
    display: block;
    padding-top: ($height / $width) * 100%;
  }
}

// ==================== 定位相关 ====================
// 绝对定位居中
@mixin absolute-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

// 绝对定位填充
@mixin absolute-full {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

// ==================== 清除浮动 ====================
@mixin clearfix {
  &:after {
    content: '';
    display: table;
    clear: both;
  }
}

// ==================== 滚动条样式 ====================
@mixin scrollbar($width: 6px, $thumb-color: #ddd, $track-color: transparent) {
  &::-webkit-scrollbar {
    width: $width;
    height: $width;
  }
  &::-webkit-scrollbar-thumb {
    background-color: $thumb-color;
    border-radius: $width / 2;
    &:hover {
      background-color: darken($thumb-color, 10%);
    }
  }
  &::-webkit-scrollbar-track {
    background-color: $track-color;
  }
}

// ==================== 响应式相关 ====================
// 媒体查询断点
@mixin respond-to($breakpoint) {
  @if $breakpoint == 'phone' {
    @media (max-width: 767px) {
      @content;
    }
  } @else if $breakpoint == 'tablet' {
    @media (min-width: 768px) and (max-width: 1023px) {
      @content;
    }
  } @else if $breakpoint == 'desktop' {
    @media (min-width: 1024px) {
      @content;
    }
  }
}

// ==================== 其他常用 ====================
// 禁用用户选择
@mixin no-select {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

// 硬件加速
@mixin hardware-accelerate {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}
